package com.heima.controller;

import com.heima.pojo.dto.VendingMachineDto;
import com.heima.pojo.vo.VendingMachineVO;
import com.heima.service.VendingMachineService;
import com.heima.utils.PageResult;
import lombok.RequiredArgsConstructor;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 赵超
 */
@RestController
@RequestMapping("/api/vm-service/vm")
@RequiredArgsConstructor
public class VendingMachineController {

    private final VendingMachineService vendingMachineService;

    @PostMapping
    public Boolean add(@RequestBody VendingMachineDto dto) {
        return vendingMachineService.save(dto) > 0;
    }

    @GetMapping("/search")
    public PageResult<VendingMachineVO> search(Integer pageIndex, Integer pageSize, String innerCode) {
        return vendingMachineService.search(pageIndex, pageSize, innerCode);
    }
}
